home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
015a
/
do1003.zip
/
CALC.SCR
< prev
next >
Wrap
Text File
|
1991-12-16
|
3KB
|
108 lines
*┌────────────────────────────────────────────────────────────────┐
*│SCRIPT: CALC.SCR - A calculator simulation │
*│ Simulates a calculator. Returns answer in │
*│ %RESULT which is available to other scripts │
*└────────────────────────────────────────────────────────────────┘
.clr
* Make sure the RESULT variable is not defined. Result might be left over
* from another script.
/CLEAR Result
* Initialize the tape row
/MATH Row 0
* Display the calculator screen
:DispCalculator
.re
/BIG DO 4
.wh
C A L C U L A T O R
.wi 3 19 38 22
Enter "C" to Clear
Enter "H" for Help
Enter "Q" to Quit
.wi full
/MATH Row 0
/FRAME ~179 ~196 ~217 ~191 ~192 ~218
/box 1 23 80 25 7 7 ""
/box 40 1 80 22 7 7 " Tape "
/box 1 18 39 22 7 7 ""
/FRAME RESET
* Initialize the formula if <enter> pressed
/SET Default ""
* Start of the calculator loop
:TOP
.go 3 24
* Get the formula and evaluate it
/GETS Calc default "" 60 UC
/IF %calc NE Q END
/IF %calc NE H HELP
/IF %calc EQ C docalc
/CLEAR Result
/SET Default ""
/MATH Row 0
.wi 42 2 79 21 clr wi full
/GOTO TOP
:docalc
* if this is a continuation calculation, append RESULT to it.
/IF %calc LK "[^,+,/,*,-]*" Start
/IF %Result NE "" Clip
/MATH Result %Result%calc
/GOTO show
:Clip
/SET Calc @trim(%calc," +-/*",L)
:start
/MATH Result %calc
:show
* show the result. Printing at the bottom of the window (row 20)
* will scroll the window
/inc row
/if %row GT 20 ShowResult
/MATH row 20
:showresult
.wi 42 2 79 21 go 1 %row
%Result
.wi full
* set the default to the last forumla and loop
/SET Default %Calc
/GOTO TOP
:HELP
.wi full clr
/SET Title "DO Calculator Help"
»bo«%title(C80)»#«
.wi 1 3 80 25
The DO Calculator can perform basic calculations using the
following operators and functions:
»wh«+»#« Addition »wh«/»#« Division
»wh«-»#« Subtraction »wh«^»#« Exponentiation
»wh«*»#« Multiplication »wh«()»#« Grouping
»wh«ABS»#« Returns the absolute value of the argument
»wh«ATAN»#« Returns the arctangent of the argument
»wh«COS»#« Returns the cosine of the argument
»wh«EXP»#« Returns the exponential
»wh«LN»#« Returns the natural logarithm of the argument
»wh«ROUND»#« Rounds a real number to an integer
»wh«SIN»#« Returns the sine of the argument
»wh«SQRT»#« Returns the square root of the argument
»wh«SQR»#« Returns the square of the argument
»wh«TRUNC»#« Truncates a real to an integer
.pg -25 clr
Enter the formula of up to 60 characters and press <enter>.
The result is displayed on the "tape". If you wish to perform
a continuing calculation, start the formula with "+,-,/,*".
Enter "C" to clear the tape and "Q" to quit.
If a calculation was performed and not cleared, the result of
the final calculation is contained in the variable "RESULT".
.pg -25 wi full clr
/GOTO DispCalculator
:END
* clear the screen and remove all variables except RESULT
.wi full clr
/CLEAR CALC
/CLEAR DEFAULT
/CLEAR ROW